
package com.tool.tcp;

import java.awt.Image;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Map;
import java.util.Random;
import java.util.regex.Pattern;

import org.come.Frame.TestSetupJframe;
import org.come.bean.ConfigureBean;
import org.come.model.Configure;
import org.come.until.UserMessUntil;

import com.gl.util.Xy2Util;

import javax.swing.*;

public class GetTcpPath {

	public static String WEI = ".tcp";
	public static String ROLE = "skin/";
	public static String BUFF = "resource/FightingSkill/持续状态/";
	public static String SKILL = "resource/FightingSkill/";
	public static String SKILLXJ="resource/FightingSkillOld/";
	public static String MOUSE = "resource/mouse/";
	public static String LIN;
	public static String PK;
	public static String STRTMP = "1";
	public static String STRTMPXJ = "1";
	public static String CLOUD1;
	public static String CLOUD2;
	public static String CLOUD3;

	public static Random random=new Random();


	static {
		LIN = MOUSE + "令牌" + WEI;
		PK = MOUSE + "PK" + WEI;
		CLOUD1 = "cloud1";
		CLOUD2 = "cloud2";
		CLOUD3 = "cloud3";
	}

	public GetTcpPath() {
	}







	public static String getRoleTcp(String skin, int type, String ColorScheme) {
		//
		if(isInteger(skin)) {
			Long ls = Long.parseLong(skin);
			if(ls>=8796093042209L && ls<9895604669985L) {
				String s = ls.toString().replace("879609304", "");
				if("旧".equals(Xy2Util.roleneworold)) {
					if("4211".equals(s)) {
						s="4211-1";
					}
					if("2211".equals(s)) {
						s="2211-1";
					}
				}
				skin = "400566/BASE/"+s;
				StringBuffer buffer = new StringBuffer();
				buffer.append(ROLE);
				buffer.append(skin);
				buffer.append("/");
				buffer.append("BASE");
				buffer.append(".HH");
				if (ColorScheme != null && !"".equals(ColorScheme)) {
					buffer.append("_");
					buffer.append(ColorScheme);
				}
				return buffer.toString();
			}else if(ls>=9895604669985L && ls<10995116297761L) {
				String s = ls.toString().replace("98956046", "");
				if("旧".equals(Xy2Util.roleneworold)) {
					if("71987".equals(s)) {
						s="71987-1";
					}
					if("69987".equals(s)) {
						s="69987-1";
					}
				}
				skin = "/500173/LMCY/"+s;
				StringBuffer buffer = new StringBuffer();
				buffer.append(ROLE);
				buffer.append(skin);
				buffer.append("/");
				buffer.append("BASE");
				buffer.append(".HH");
				if (ColorScheme != null && !"".equals(ColorScheme)) {
					buffer.append("_");
					buffer.append(ColorScheme);
				}
				return buffer.toString();
			}else if(ls>=10995116297761L && ls<12094627925537L) {
				String s = ls.toString().replace("1099511629", "");
//    			skin = "/500173/dslmy/"+s;
				StringBuffer buffer = new StringBuffer();
				buffer.append(ROLE);
//    	        buffer.append(skin);
				buffer.append("/");
				buffer.append("BASE");
				buffer.append(".HH");
				if (ColorScheme != null && !"".equals(ColorScheme)) {
					buffer.append("_");
					buffer.append(ColorScheme);
				}
				return buffer.toString();
			}else if(ls>=12094627925537L){
				String s = ls.toString().replace("1209462792", "");
//    			skin = "/500173/wsxy/"+s;
				StringBuffer buffer = new StringBuffer();
				buffer.append(ROLE);
//    	        buffer.append(skin);
				buffer.append("/");
				buffer.append("BASE");
				buffer.append(".HH");
				if (ColorScheme != null && !"".equals(ColorScheme)) {
					buffer.append("_");
					buffer.append(ColorScheme);
				}
				return buffer.toString();
			}else {
				StringBuffer buffer = new StringBuffer();
				buffer.append(ROLE);
				//强制指定 4294987307-神秀生的剑皮肤,42949692972-玲珑女的鞭子皮肤,47244662268-云中君的双环皮肤，42949693972-霜月灵的钩子皮肤，68719500744-临九渊的飘带皮肤,4294990304-镜花影的剑皮肤，51539629563-青阳使的枪皮肤,42949696967-游无极的刀皮肤,4294991303-游无极的剑皮肤,
				if(skin.equals("4294987307")||skin.equals("42949692972")||skin.equals("47244662268")||skin.equals("38654726676")||skin.equals("68719500744")||skin.equals("4294990304")||skin.equals("51539629563")||skin.equals("42949696967")||skin.equals("4294991303")){
					skin = Xy2Util.MODEL.get(skin);
				}
				buffer.append(skin);
				buffer.append("/");
				buffer.append(SpriteFactory.getActionType(type));
				buffer.append(WEI);
				if (ColorScheme != null && !"".equals(ColorScheme)) {
					buffer.append("_");
					buffer.append(ColorScheme);
				}
				return buffer.toString();
			}
		}
		else {
			StringBuffer buffer = new StringBuffer();
			buffer.append(ROLE);
			buffer.append(skin);
			buffer.append("/");
			String dongzuo=SpriteFactory.getActionType(type);//幻方
			if (skin!=null&&skin.equals("9999"))
				if (dongzuo.equals("attack"))
					dongzuo=dongzuo+"-"+random.nextInt(3);
			buffer.append(dongzuo);
			buffer.append(SpriteFactory.getActionType(type));
			buffer.append(WEI);
			if (ColorScheme != null && !ColorScheme.equals("")) {
				buffer.append("_");
				buffer.append(ColorScheme);
			}
			return buffer.toString();
		}
	}

	private static Image  getImage(String tcps, String string) {
		// TODO Auto-generated method stub
		return null;
	}

	static Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
	public static boolean isInteger(String str) {
		return pattern.matcher(str).matches();
	}
	public static String getBuffTcp(String tcp) {
		return BUFF + tcp + WEI;
	}

	//    public static String getSkillTcp(String tcp) {
//        return SKILL + tcp + WEI;
//    }
	public static String getSkillTcp(String tcp) {

		if("1".equals(GetTcpPath.STRTMPXJ)) {//新版法术

			return SKILL + tcp + WEI;
		}else {//旧版法术

			return SKILLXJ + tcp + WEI;
		}

	}

	public static String getMouseTcp(String tcp) {
		return MOUSE + tcp + WEI;
	}
	//飞行器相关
	public static String getflytcp(String tcp){
		return ROLE+tcp+WEI;
	}

	public static String getflyShadowtcp(String tcp){
		return ROLE+tcp+WEI;
	}
}
